<?php
  
  class myCreditMemoSearchForm extends sfForm{
    public function configure(){
      $this->setWidgets(
        array(
          'credit_type' => 
            new sfWidgetFormSelect(
              array(
                'choices'=>ListDocumentTypesPeer::getList('CREDIT',true),
              )
            ),
          'invoice_type' => 
            new sfWidgetFormSelect(
              array(
                'choices'=>ListDocumentTypesPeer::getList('INVOICE',true),
              )
            ),
          'credit_number_from' => new sfWidgetFormInput(),
          'credit_number_to' => new sfWidgetFormInput(),
          'invoice_number_from' => new sfWidgetFormInput(),
          'invoice_number_to' => new sfWidgetFormInput(),
          'credit_date_from' => new sfWidgetFormDate(),
          'credit_date_to' => new sfWidgetFormDate(),
          'customer_name' => new sfWidgetFormInput(),
          'show_void_only' => new sfWidgetFormInputCheckbox(),
        )
      );
      
      $this->setValidators(array(
        'credit_type' => new sfValidatorString(array('required'=>false,)),
        'credit_number_from' => new sfValidatorString(array('required'=>false,)),
        'credit_number_to' => new sfValidatorString(array('required'=>false,)),
        'invoice_type' => new sfValidatorString(array('required'=>false,)),
        'invoice_number_from' => new sfValidatorString(array('required'=>false,)),
        'invoice_number_to' => new sfValidatorString(array('required'=>false,)),
        'credit_date_from' => new sfValidatorDate(array('required'=>false,)),
        'credit_date_to' => new sfValidatorDate(array('required'=>false,)),
        'customer_name' => new sfValidatorString(array('required'=>false,'max_length'=>50,)),
        'show_void_only' => new sfValidatorString(array('required'=>false,)),
    ));
      
      $this->widgetSchema->setLabels(
        array(
          'credit_type' => 'Type:',
          'credit_number_from' => 'Debit# From:',
          'credit_number_to' => ' to ',
          'invoice_type' => 'Invoice Type:',
          'invoice_number_from' => 'Invoice# From:',
          'invoice_number_to' => ' to ',
          'credit_date_from' => 'Date From:',
          'credit_date_to' => ' to ',
          'customer_name' => 'Customer Name',
          'show_void_only' => 'Show Void Only',
        )
      );
      
      $this->widgetSchema['customer_name']->setAttribute('size',50);
      
      
      $years = range(date('Y')-50,date('Y')+1);
      $this->widgetSchema['credit_date_from']->setOption('years',array_combine($years,$years));
      $this->widgetSchema['credit_date_to']->setOption('years',array_combine($years,$years));
      $this->widgetSchema['show_void_only']->setOption('value_attribute_value','Y');
      
      $this->widgetSchema->setNameFormat('skey_credit[%s]');
      
    }
  }